package org.liveboardgames.agricola.vo.board
{
    import com.adobe.cairngorm.vo.IValueObject;
    
    import org.liveboardgames.agricola.vo.card.ActionCard;
    import org.liveboardgames.agricola.vo.common.Target;
    import org.liveboardgames.common.dictionary.collections.HashCollection;

    [RemoteClass(alias="org.liveboardgames.agricola.domain.board.BoardTile")]
	[Bindable]
    public class BoardTile implements Target, IValueObject
    {
        /** The unique identifier of the board tile <i>within the whole data base</i>. */
        public var uniqueId:int;
        
        /** The unique identifier of the board tile <i>within the board</i>. */
        public var id:int;
        
        /** The action card linked to the tile of the board game. */
        public var actionCard:ActionCard;

        /**
         * The resources that are present on the tile itself.
         * The resources map is really a Map<ResourceType, Integer>
         */
        private var _resources:HashCollection;

        public var type:String;

		public function get resources():HashCollection
		{
			if (this._resources == null)
			{
				this._resources = new HashCollection();
			}
			return this._resources;
		}
		
		public function set resources(col:HashCollection):void
		{
			this._resources = col;
		}
		
        public function addResource(type:String, quantity:int):void
        {
            if (resources.getValue(type) != null)
            {
                quantity += resources.getValue(type);
            }
            resources.put(type, quantity);
        }
    }
}